package org.ysling.litemall.core.tenant.interceptor;
/**
 *  Copyright (c) [ysling] [927069313@qq.com]
 *  [litemall-plus] is licensed under Mulan PSL v2.
 *  You can use this software according to the terms and conditions of the Mulan PSL v2.
 *  You may obtain a copy of Mulan PSL v2 at:
 *              http://license.coscl.org.cn/MulanPSL2
 *  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 *  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 *  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 *  See the Mulan PSL v2 for more details.
 */
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Nonnull;
import java.util.ArrayList;

/**
 * 注册多租户拦截器
 * @author Ysling
 */
@Component
public class TenantConfigure implements WebMvcConfigurer {

    @Autowired
    private TenantInterceptor tenantInterceptor;

    /**
     * 注册Interceptor
     * @param registry 注册器
     */
    @Override
    public void addInterceptors(@Nonnull InterceptorRegistry registry) {
        //拦截地址
        ArrayList<String> addPath = new ArrayList<>();
        addPath.add("/wx/**");
        addPath.add("/admin/**");
        //自定义拦截器
        registry.addInterceptor(tenantInterceptor).addPathPatterns(addPath);
    }

}



